package com.example.miaopin.fragment;

import org.json.JSONObject;

import com.example.miaopin.MainActivity;
import com.example.miaopin.R;
import com.example.miaopin.adapter.ContentAdapter;
import com.example.miaopin.utils.ImageUtil;
import com.example.miaopin.utils.ImageUtils2;
import com.example.miaopin.utils.SPUtil;
import com.viewpagerindicator.TabPageIndicator;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

/**
 * @author Administrator 秒评秒赞fragment
 */
public class MiaopingF extends BaseFragment {

	private String[] CONTENT;
	private TextView namem;
	private ImageView image;
	private SPUtil spUtil;

	@Override
	protected View initview() {
		view = inflater1(R.layout.miaoping);
		spUtil = new SPUtil(mContext);
		if (spUtil.getBoolean("isLogin", false)) {
			login();
		}
		CONTENT = mContext.getResources().getStringArray(R.array.miaozan);
		ContentAdapter adapter = new ContentAdapter(((MainActivity) mContext).getSupportFragmentManager(), CONTENT);
		ViewPager pager = (ViewPager) view.findViewById(R.id.viewpaget_m);
		image = (ImageView) view.findViewById(R.id.imagem);
		image.setOnClickListener(this);
		namem = (TextView) view.findViewById(R.id.namem);
		pager.setAdapter(adapter);

		TabPageIndicator indicator = (TabPageIndicator) view.findViewById(R.id.indicator);
		indicator.setViewPager(pager);
		return view;
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {

		case R.id.imagem:
			login();
			break;

		default:
			break;
		}
	}

	@Override
	protected void setTtitle(String string) {
		namem.setText(string);

		spUtil.putBoolean("isLogin", true);
	}

	@Override
	protected void setImage(Bitmap bitmap) {
		image.setImageBitmap(ImageUtils2.getRoundedCornerBitmap(bitmap));
	}

}
